# -*- coding: utf-8 -*-

"""
  @author: tangliqi
  @date: 2022/8/15 14:42
  @python version: 3.6 
  
  ---------------------------------------
  @desc: python算法实现 => 斐波那契数列.py
"""


# 通过生成器方式实现
def fibonacci(n):
    a, b, counter = 0, 1, 0
    while True:
        if counter > n:
            return n
        yield a
        a, b = b, a + b
        counter += 1


f = fibonacci(10)  # f是一个迭代器，由生成器返回生成
